<template>
<div class="oe-ruleManage" v-loading="loading">
    <top-tip :batchTitle="batchTitle" :examTitle="examTitle"></top-tip>
    <div class="oe-rule-content">
        <div class="oe-manage-search">
            <span class="oe-wrong-select">
                选择试卷：
                <a-select placeholder="请选择试卷" v-model="searchExamStruct" style="width: 200px" @change="getQuestionTypeStatisticsList">
                    <a-select-option :value="item" v-for="(item, index) in examStruct" :key="index">试卷{{ item }}</a-select-option>
                    <a-select-option :value="item" v-for="(item, index) in examRepairStruct" :key="index">试卷{{ item }}</a-select-option>
                </a-select>
            </span>
        </div>
        <div class="oe-manage-contain">
            <a-table :columns="modalColumns" :dataSource="modalList" :rowSelection="modalSelection" :pagination ="false" >

            </a-table>
        </div>
    </div>
</div>
</template>

<script>
import topTip from '@/components/top-tip/index.vue';
import GetOperationList from '@/lib/mixin/methods.js';
export default {
    name: 'questionTypeAnalysis',
    components: {
        topTip
    },
    mixins: [GetOperationList],
    data() {
        return {
            q_type: [
                '',
                '单选题',
                '多选题',
                '判断',
                '',
                '填空题',
                '问答题',
                '匹配题',
                '阅读理解',
                '完形填空',
                '文件作答题',
                '视听题'
            ],
            examStruct: [],
            examRepairStruct: [],
            //数据详情
            stuAnswerList: [],

            modalColumns: [{
                    title: '题型',
                    dataIndex: 'QuestionName',
                    key: 'QuestionName',
                },
                {
                    title: '题型总数',
                    dataIndex: 'AllCount',
                    key: 'AllCount',
                },
                {
                    title: '非常简单数量',
                    dataIndex: 'VeryEasyCount',
                    key: 'VeryEasyCount',
                },
                {
                    title: '简单数量',
                    dataIndex: 'EasyCount',
                    key: 'EasyCount',
                },
                {
                    title: '一般数量',
                    dataIndex: 'CommonlyCount',
                    key: 'CommonlyCount',
                },
                {
                    title: '困难数量',
                    dataIndex: 'DifficultyCount',
                    key: 'DifficultyCount',
                },
                {
                    title: '非常困难数量',
                    dataIndex: 'VeryDifficultyCount',
                    key: 'VeryDifficultyCount',
                }

            ],
            modalList: [],
            examTitle:'',
            batchTitle:'',
        };
    },
    props: {
        examid: {
            type: String,
            default: ''
        },
        searchExamStruct: {
            type: String,
            default: ''
        },
    },
    mounted(){
      this.getOperation()
      this.getQuestionTypeStatisticsList();
      this.getExamStructData()
    },
    methods: {
        getOperation() {
          this.loading = true;
          this.GetOperationList('examId',this.examid).then((rst) => {
            this.loading = false;
            if (rst.code === 1) {
              this.examTitle = rst.examTitle
              this.batchTitle = rst.batchTitle
            } else {
              this.$message.error(rst.msg);
            }
          });
        },
        //获取试卷套数
        getExamStructData() {
            var that = this;
            this.$http
                .post('/api/examStatistics/ExamAnaly/getExamStructData', {
                    examId: this.examid
                })
                .then((res) => {
                    if (res.code > 0) {
                        this.examStruct = res.examStruct;
                        this.examRepairStruct = res.examRepairStruct;
                    } else {
                        this.$message.warning(res.msg);
                    }
                });
        },
        //数据统计详情
        getQuestionTypeStatisticsList() {
            this.loading = true;
            var that = this;
            this.$http
                .post('/api/examStatistics/ExamAnaly/getQuestionTypeStatisticsList', {
                    examId: this.examid,
                    examStruct: this.searchExamStruct
                }).then((rst) => {
                    this.loading = false;
                    if (rst.code > 0) {
                        this.stuAnswerList = rst.list;
                        this.modalList = [];
                        if (rst.list.length) {
                            rst.list.forEach((item, index) => {
                                // let questionType = this.q_type[Number(item.QuestionType)]
                                this.modalList.push({
                                    ...item,
                                    // questionType:questionType
                                });
                            });
                        }
                    } else {
                        that.$message.warning(rst.msg);
                    }
                });
        },

    },
};
</script>
